//在定义类时, 为类中的属性或方法定义泛型类型 在创建类的实例时, 再指定特定的泛型类型
(() => {
  class GenericNumber<T> {
    zeroValue: T;
    add: (x: T, y: T) => T;
  }

  let myGenericNumber = new GenericNumber<number>();
  myGenericNumber.zeroValue = 0;
  myGenericNumber.add = function (x, y) {
    return x + y;
  };

  let myGenericString = new GenericNumber<string>();
  myGenericString.zeroValue = "abc";
  myGenericString.add = function (x, y) {
    return x + y;
  };

  console.log(myGenericNumber.add(myGenericNumber.zeroValue, 12));
  console.log(myGenericString.add(myGenericString.zeroValue, "test"));

})();
